package com.taobao.top.converter
{
	import com.taobao.top.model.*;
	import com.taobao.top.TOPUtil;
	public class UserConverter
	{
		public function UserConverter()
		{
		}
		
		public static function convert(userObj:Object):User
		{
			var user:User = new User;
			user.alipay_bind= userObj.alipay_bind;
			user.auto_repost= userObj.auto_repost;
			user.birthday = userObj.birthday;
			if (userObj.buyer_credit != null)
			{
				(user.buyer_credit as UserCredit).good_num = userObj.buyer_credit.good_num;
				(user.buyer_credit as UserCredit).level = userObj.buyer_credit.level;
				(user.buyer_credit as UserCredit).score = userObj.buyer_credit.score;
				(user.buyer_credit as UserCredit).total_num = userObj.buyer_credit.total_num;
			}
			user.consumer_protection = userObj.consumer_protection;
			user.created = TOPUtil.getCustomDate( userObj.created);
			user.has_more_pic= userObj.has_more_pic;
			user.item_img_num= userObj.item_img_num;
			user.item_img_size= userObj.item_img_size;
			user.last_visit = userObj.last_visit;
			if (userObj.location != null)
			{
				(user.location as Location).address = userObj.location.address;
				(user.location as Location).city = userObj.location.city;
				(user.location as Location).country = userObj.location.country;
				(user.location as Location).district = userObj.location.district;
				(user.location as Location).state = userObj.location.state;
				(user.location as Location).zip = userObj.location.zip;
			}
			user.nick= userObj.nick;
			user.promoted_type= userObj.promoted_type;
			user.prop_img_num= userObj.prop_img_num;
			user.prop_img_size = userObj.prop_img_size;
			if (userObj.seller_credit != null)
			{
				(user.seller_credit as UserCredit).good_num = userObj.seller_credit.good_num;
				(user.seller_credit as UserCredit).level = userObj.seller_credit.level;
				(user.seller_credit as UserCredit).score = userObj.seller_credit.score;
				(user.seller_credit as UserCredit).total_num = userObj.seller_credit.total_num;
			}
			user.sex = userObj.sex;
			user.status= userObj.status;
			user.type= userObj.type;
			user.user_id = userObj.user_id;
			return user;
		}
	}
}